﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BungaloEngine.Core;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace BungaloEngine.Types
{
    abstract class Sprite : Entity, IRenderable
    {
        protected virtual Texture2D GetTexture()
        {   return Engine.pTextureManager.GetTexture(this); }
        protected virtual Color         GetColor()
        {   return Color.White; }
        protected virtual Rectangle     GetBounds()
        {
            return new Rectangle((int)GetWorldPosition().X, (int)GetWorldPosition().Y, GetTexture().Width, GetTexture().Height);
        }

        public Sprite(string texture)
        {
            Engine.pTextureManager.RegisterTexturedObject(this, texture);
        }

        public virtual void Render()
        {
            Engine.pSpriteBatch.Begin();
            Engine.pSpriteBatch.Draw(GetTexture(), GetBounds(), GetColor());
            Engine.pSpriteBatch.End();
        }
    }
}
